home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / SLAX 6.0.8 / slax-6.0.8.iso / slax / base / 006-devel.lzm / usr / include / arts / qiomanager.h < prev    next >
Encoding:
C/C++ Source or Header  |  2005-09-10  |  2.8 KB  |  107 lines

  1.     /*
  2.  
  3.     Copyright (C) 1999-2001 Stefan Westerfeld
  4.                             stefan@space.twc.de
  5.  
  6.     This library is free software; you can redistribute it and/or
  7.     modify it under the terms of the GNU Library General Public
  8.     License as published by the Free Software Foundation; either
  9.     version 2 of the License, or (at your option) any later version.
  10.   
  11.     This library is distributed in the hope that it will be useful,
  12.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  14.     Library General Public License for more details.
  15.    
  16.     You should have received a copy of the GNU Library General Public License
  17.     along with this library; see the file COPYING.LIB.  If not, write to
  18.     the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  19.     Boston, MA 02111-1307, USA.
  20.  
  21.     */
  22.  
  23. /*
  24.  * BC - Status (2002-03-08): QIOManager.
  25.  *
  26.  * QIOManager is kept binary compatible.
  27.  */
  28.  
  29. #ifndef QIOMANAGER_H
  30. #define QIOMANAGER_H
  31.  
  32. #include "iomanager.h"
  33. #include <qobject.h>
  34. #include <qtimer.h>
  35. #include <qsocketnotifier.h>
  36. #include <list>
  37. #include "arts_export.h"
  38.  
  39. namespace Arts {
  40.  
  41. class QIOWatch;
  42. class QTimeWatch;
  43.  
  44. /**
  45.  * QIOManager performs MCOP I/O inside the Qt event loop. This way, you will
  46.  * be able to receive requests and notifications inside Qt application. The
  47.  * usual way to set it up is:
  48.  *
  49.  * <pre>
  50.  * KApplication app(argc, argv);    // as usual
  51.  *
  52.  * Arts::QIOManager qiomanager;
  53.  * Arts::Dispatcher dispatcher(&qiomanager);
  54.  * ...
  55.  * return app.exec();               // as usual
  56.  * </pre>
  57.  */
  58.  
  59. class ARTS_EXPORT QIOManager : public IOManager {
  60. protected:
  61.     friend class QIOWatch;
  62.     friend class QTimeWatch;
  63.  
  64.     std::list<QIOWatch *> fdList;
  65.     std::list<QTimeWatch *> timeList;
  66.  
  67.     void dispatch(QIOWatch *ioWatch);
  68.     void dispatch(QTimeWatch *timeWatch);
  69.  
  70. public:
  71.     QIOManager();
  72.     ~QIOManager();
  73.  
  74.     void processOneEvent(bool blocking);
  75.     void run();
  76.     void terminate();
  77.     void watchFD(int fd, int types, IONotify *notify);
  78.     void remove(IONotify *notify, int types);
  79.     void addTimer(int milliseconds, TimeNotify *notify);
  80.     void removeTimer(TimeNotify *notify);
  81.  
  82.     /**
  83.      * This controls what QIOManager will do while waiting for the result
  84.      * of an MCOP request, the possibilities are:
  85.      *
  86.      * @li block until the request is completed (true)
  87.      * @li open a local event loop (false)
  88.      *
  89.      * It is much easier to write working and reliable code with blocking
  90.      * enabled, so this is the default. If you disable blocking, you have
  91.      * to deal with the fact that timers, user interaction and similar
  92.      * "unpredictable" things will possibly influence your code in all
  93.      * places where you make a remote MCOP call (which is quite often in
  94.      * MCOP applications).
  95.      */
  96.     void setBlocking(bool blocking);
  97.  
  98.     /**
  99.      * Query whether blocking is enabled.
  100.      */
  101.     bool blocking();
  102. };
  103.  
  104. }
  105.  
  106. #endif
  107.